<?php
class Model_Specjalizacja{

    private $table_name = 'specjalizacja';
    protected $results;

public function __construct(){
        require_once("../../dbConnection.php");
}
public function get($specjalizacja_id){
       $this->results = mssql_query("SELECT * FROM $this->table_name WHERE id='$specjalizacja_id'");
       $specialization = mssql_fetch_assoc($this->results);
  return $specialization;
}
public function getAllForKierunek($kierunek_id){
       $this->results = mssql_query("SELECT * FROM $this->table_name WHERE kierunek_id='$kierunek_id'");
       $key = 0;
       while ($row = mssql_fetch_assoc($this->results)) {
             $specialization[$key] = $row;
             $specialization[$key]['nazwa'] = iconv("CP1250","utf-8",$specialization[$key]['nazwa']);
             $key++;
       }
  return $specialization;
}
public function insert($nazwa,$kierunek_id){
       $this->results = "INSERT INTO $this->table_name VALUES('$nazwa','$kierunek_id')";
       return mssql_query($this->results);
}
public function delete($spec_id){
       $this->results = "DELETE FROM $this->table_name WHERE id=$spec_id";
       return mssql_query($this->results);
}
public function update($spec_id,$name){
       $this->results = "UPDATE $this->table_name SET nazwa='$name' WHERE id=$spec_id";
       return mssql_query($this->results);
}
public function __destruct(){
	mssql_free_result($this->results);
	//mssql_close($con);
}
}
?>
